<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Bit Cloud, Inc.">
    <meta name="author" content="typefo">
    <link rel="icon" href="favicon.ico">
    <title>pbxMon System</title>
    <link type="text/css" rel="stylesheet" href="/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link type="text/css" rel="stylesheet" href="/css/interface.css">
  </head>
  <body>
    <nav class="navbar navbar-default navbar-static-top">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand">
            <img alt="Brand" src="/img/logo.png" width="34" style="margin-top:-8px" />
          </a>
          <a class="navbar-brand">pbxMon</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li><a href="/cdr">通话记录</a></li>
            <li><a href="/server">网关管理</a></li>
            <li><a href="/route">路由管理</a></li>
            <li><a href="/interface">接口管理</a></li>
            <li><a href="/report">数据报表</a></li>
            <li><a href="/system/status">服务器状态</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="/system/option"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 系统设置</a></li>
            <li><a href="/logout"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> 退 出</a></li>
          </ul>
        </div>
      </div>
    </nav>
    <div class="container">
      <div class="row">
        <ol class="breadcrumb">
          <li><a href="/cdr">Home</a></li>
          <li><a href="/interface">Interface</a></li>
          <li class="active">Data</li>
          <li class="pull-right add"><a class="btn btn-success btn-xs" href="/interface/create"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 创 建</a></li>
        </ol>
      </div>
      <div class="row">
            <table class="table table-hover table-condensed">
              <thead>
                <tr><th class="tab-left">#</th><th>接口名称</th><th>IP 地址</th><th>端 口</th><th>呼入编码</th><th>呼出编码</th><th>备注信息</th><th>删 除</th><th class="tab-right">编 辑</th></tr>
              </thead>
              <tbody>
              <?php
              if (isset($data)) {
                foreach ($data as $obj) {
                  echo '<tr><td><span class="glyphicon glyphicon-globe" aria-hidden="true"></span></td><td>',$obj['name'],'</td><td>',$obj['ip'],'</td><td>',$obj['port'],'</td><td>',$obj['in_code'],'</td><td>',$obj['out_code'],'</td><td>',htmlspecialchars(mb_substr($obj['description'], 0, 18, 'UTF-8'), ENT_QUOTES),'</td><td><button class="btn btn-default btn-xs" onClick="drop(',$obj['id'],')"><span class="glyphicon glyphicon-trash"></span> 删 除</button></td><td><a class="btn btn-default btn-xs" href="/interface/edit?id=',$obj['id'],'"><span class="glyphicon glyphicon-edit"></span> 编 辑</a></td></tr>';
                }
              }
              ?>
              </tbody>
            </table>
          </div>
    </div>
  </body>
  <script type="text/javascript" src="/js/jquery.min.js"></script>
  <script type="text/javascript" src="/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="/js/layer.js"></script>
  <script type="text/javascript">
  function drop(id) {
      layer.confirm('亲，确定要删除？', {
        btn: ['是','否'], icon: 3
      }, function(){
        var url = '/interface/delete?id=' + id;
        $.get(url, function(response, status){
          if (status == 'success') {
            if (response.status == 200) {
              layer.msg('删除成功!', {icon: 1, time: 1000});
              setTimeout(function() {
                window.location.reload();
              }, 1000);
            } else {
              layer.msg('抱歉，暂时无法删除!', {icon: 2});
            }
          } else {
            layer.msg('服务器通讯错误!', {icon: 2});
          }
        });
      });
  }
  </script>
</html>
